package cn.gson.crm.controller.classroom;

import java.util.List;

import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import cn.gson.crm.controller.BaseServlet;
import cn.gson.crm.model.dao.ClassroomDao;
import cn.gson.crm.model.dao.StudentClassDao;
import cn.gson.crm.model.entity.Classroom;
import cn.gson.crm.model.entity.Student;

/**
 * 进入分配班级页面--未指定classType
 */
@WebServlet("/class/search")
public class ClassAllocationSearch extends BaseServlet {
	private static final long serialVersionUID = 1L;
	private StudentClassDao stuClaDao = new StudentClassDao();
	private ClassroomDao claDao = new ClassroomDao();
       
	@Override
	protected void get(HttpServletRequest request, HttpServletResponse response) throws Exception {
		super.get(request, response);
		String name = request.getParameter("userName");
		String p = request.getParameter("page");
		
		if(p == null || p.isEmpty()){
			p = "1";
		}
		//将当前页数进行的类型转换
		Integer page = Integer.parseInt(p);
		Integer totalPage = stuClaDao.getTotalPage("正常", "已分配", name, 2, 0);
		List<Student> stuList = stuClaDao.getStudentList(page, "正常", "已分配", name , 2, 0);
		List<Classroom> claList2 = claDao.getListClass(2);
 		request.setAttribute("totalPage", totalPage);
		request.setAttribute("stuList", stuList);
		request.setAttribute("claList2", claList2);
		request.setAttribute("page", page);
		request.setAttribute("queryString", noPageQueryString(request));
		getServletPathAndForward(request, "class/allocation_class.jsp");
	}
}
